Skip to content

[optimize] uuid compatibility && [bug] fix img dom not find #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 22, 2024

Conversation

Hiram-Wong
Copy link
Contributor

  1. 修复产生错误时没有找到 imgdom 元素
  2. 兼容不同环境下 uuid 生成方式, 优先级 crypto.randomUUID -> crypto.getRandomValues -> Math.random
static generateUUID() {
        if (crypto && typeof crypto.randomUUID === 'function') {
            return crypto.randomUUID();
        } else if (crypto && typeof crypto.getRandomValues === 'function') {
            return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
                (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)
            );
        } else {
            return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
                const r = (Math.random() * 16) | 0,
                  v = c == 'x' ? r : (r & 0x3) | 0x8;
                return v.toString(16);
              });
        }
    }

Copy link

vercel bot commented Dec 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
drpy-node ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 22, 2024 2:08am

@hjdhnx hjdhnx merged commit 010a468 into hjdhnx:main Dec 22, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants